﻿@using SCMS.Resources
@model SCMS.UI.Models.ORequest
@{
    string updateTarget = Model.FromPP ? "requestDiv" : "popup-page";
    string loadingElement = Model.FromPP ? "loading" : "popup-loading";
    string onbegin = Model.FromPP ? "" : string.Format("ShowDialogue('{0}')", Resources_frank.OrderRequest_AddNewItem4OR_AddNewItem);
    string onsuccess = Model.FromPP ? "" : "disablebutton('orbutton');ClearFormById('#' + 'frmORItem');CenterPopup();";
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        UpdateTargetId = updateTarget,
        LoadingElementId = loadingElement,
        HttpMethod = "Post",
        Url = Url.Action("SaveOrderRequest"),
        OnBegin = onbegin,
        OnSuccess = onsuccess
    };
}
<script src="@Url.Content("~/Scripts/js/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Resources_frank.OrderRequest_LoadOrderRequest_NewOrderRequest</h3></div>
    <br />
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
            
        <table width="98%" align="center" cellpadding="0">
            <tr>
                <th align="center" width="33%">
                    @Resources_frank.Global_String_RefNo
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.Global_String_Date
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.Global_String_ORCurrency
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.TextBoxFor(m => m.OrderRequestNo, new { @readonly = "readonly" })
                    @Html.HiddenFor(m => m.FromPP)
                </td>
                <td align="center" colspan="2">
                    @Html.EditorFor(m => m.IssueDate)
                    @Html.ValidationMessageFor(m => m.IssueDate)
                </td>
                <td align="center" colspan="2">
                    @Html.DropDownListFor(x => x.CurrencyID, Model.currencies, Resources_frank.Global_String_PleaseSelect, new { @id = "currencyId" })
                    @Html.ValidationMessageFor(x => x.CurrencyID)
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.Global_String_ProjectProgramme
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.Budget_CategoryList_ProjectNo
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.Budget_CategoryList_Donor
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.DropDownListFor(x => x.ProjectId, Model.Projects, Resources_frank.Global_String_PleaseSelect, new { @id = "dplProject", onchange = "javascript:selectedIndexChangePONos(this)" })
                    @Html.ValidationMessageFor(x => x.ProjectId)
                </td>
                <td align="center" colspan="2">
                    <div id="ProjectNoDiv">
                        @Html.DropDownListFor(x => x.ProjectDonorId, Model.ProjectNos, Resources_frank.Global_String_PleaseSelect, new { @id = "dplProNo", onchange = "javascript:GetDonor(this)" })
                        @Html.ValidationMessageFor(x => x.ProjectDonorId)</div>
                </td>
                <td align="center" colspan="2">
                    <div id="donorDiv" style="font-size: 12px;">
                    </div>
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.OrderRequest_EditOrderRequest_RequestedDeliveryDate
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.OrderRequest_EditOrderRequest_RequestedDeliveryDestination
                </th>
                <th align="center" colspan="2">
                    @Resources_frank.OrderRequest_EditOrderRequest_FinalDeliveryDestination
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.EditorFor(m => m.RequestDate)
                    @Html.ValidationMessageFor(m => m.RequestDate)
                </td>
                <td align="center" width="32%" id="reqDelDiv">
                    @Html.DropDownListFor(x => x.RequestDelivLocationID, Model.RequestDelivLocations, Resources_frank.Global_String_PleaseSelect, new { id = "RequestDelivLocationID" })
                    @Html.ValidationMessageFor(x => x.RequestDelivLocationID)
                </td>
                <td width="1%" title="@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress">
                    <a href="#" onclick="ShowDialogue('@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress');sendRequest('/OrderRequest/AddNewLocation4OR?final=false&otherDDSelectedId='+document.getElementById('FinalDelivLocationID').value, 'popup-page', 'popup-loading');CenterPopup();"><img src="../../Content/images/Add-Green-Button-icon.png" alt="@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress" /></a>
                </td>
                <td align="center" width="32%" id="finalDelivDiv">
                    @Html.DropDownListFor(x => x.FinalDelivLocationID, Model.FinalDelivLocations, Resources_frank.Global_String_PleaseSelect, new { id = "FinalDelivLocationID" })
                    @Html.ValidationMessageFor(x => x.FinalDelivLocationID)
                </td>
                <td width="1%" title="@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress">
                    <a href="#" onclick="ShowDialogue('@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress');sendRequest('/OrderRequest/AddNewLocation4OR?final=true&otherDDSelectedId='+document.getElementById('RequestDelivLocationID').value, 'popup-page', 'popup-loading');CenterPopup();"><img src="../../Content/images/Add-Green-Button-icon.png" alt="@Resources_frank.OrderRequest_AddNewLocation4OR_AddNewDelivAddress" /></a>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" id="orbutton" class="btn green" value="  @Resources_frank.Global_String_Proceed  " />
                </td>
            </tr>
        </table>    
    }
</div>
<div id="tempLocation" style="display: none;" />
